import QtQuick 2.0

Rectangle{
    x:600
    y:100
    width: 80
    height: 300
    color: "white"
    ListView{
        anchors.fill: parent
        anchors.margins: 20
        clip: true
        model: 100
        delegate: numberDelegate
        spacing: 5
        //boundsBehavior: Flickable.DragAndOvershootBounds //默认值，视图可以拖拽和翻阅
        //boundsBehavior: Flickable.StopAtBounds //视图不可以移动到它的边界外
        boundsBehavior: Flickable.DragOverBounds //视图可以拖拽到边界外，但是边界上翻阅无效
        //snapMode: ListView.NoSnap //默认值，允许视图元素在任何位置停止
        //snapMode: ListView.SnapToItem //视图顶部将会与元素对象的顶部对齐
        snapMode: ListView.SnapOneItem //当鼠标或触摸释放时，视图将会停止在第一个可见元素

    }
    Component{
        id: numberDelegate
        Rectangle{
            width: 40
            height: 40
            color: "lightGreen"
            Text {
                anchors.centerIn: parent
                font.pixelSize: 10
                text: index
            }
        }
    }
}
